package com.example.cgq.business;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.CompoundButton;
import android.widget.Switch;

import com.com.cgq.data.exchenge.SettingDataToFile;

public class Setting extends AppCompatActivity {

    private Switch mSeitchIsCanLeftDrag;
    private Switch mSetIsHideViewPage;
    private SettingDataToFile mSettingData;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        initView();
        initData();
        SetBarTitleName();
        SetisCanLeftDrag();
        SetisHideViewPage();
    }

    public void initData() {
        mSettingData = new SettingDataToFile(Setting.this);
        mSeitchIsCanLeftDrag.setChecked(mSettingData.getIscanLeftDrag());
        mSetIsHideViewPage.setChecked(mSettingData.getIsShowViewPage());
    }

    public void initView() {
        mSeitchIsCanLeftDrag = (Switch) findViewById(R.id.id_switch_dragLeft);
        mSetIsHideViewPage = (Switch) findViewById(R.id.id_switch_hide_viewPage);
    }


    public void SetBarTitleName() {
        ActionBar actionBar=getSupportActionBar();
        actionBar.setTitle("设置");
    }

    public void SetisCanLeftDrag() {
        mSeitchIsCanLeftDrag.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSettingData.setIscanLeftDrag(isChecked);
                //Log.i("tag", isChecked + "sett");
            }
        });
    }


    public void SetisHideViewPage() {
        mSetIsHideViewPage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSettingData.setIsShowViewPage(isChecked);
                Log.i("tag", isChecked + "sett");
            }
        });
    }

}
